const jwt = require('jsonwebtoken')

class JWT {
    static secret = 'mySecret'

    static generate(value, expires) {
        return jwt.sign(value, JWT.secret, {
            expiresIn: expires
        })
    }

    static verify(token) {
        try {
            return jwt.verify(token, JWT.secret)
        } catch (err) {
            console.log('token 验证出错：');
            console.log(err);
            return false
        }
        
    }
}

module.exports = JWT;
